package org.apache.dolphinscheduler.dao.mapper;

import org.apache.dolphinscheduler.dao.entity.ProductOrder;
import org.apache.dolphinscheduler.dao.vo.CountVo;

import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author denggh
 * @since 2023-06-15
 */
public interface ProductOrderMapper extends BaseMapper<ProductOrder> {

    IPage<ProductOrder> queryProductOrderPage(Page page,
                                              @Param("userId") Integer userId,
                                              @Param("orderType") Integer orderType,
                                              @Param("payModel") Integer payModel,
                                              @Param("taskStatus") Integer taskStatus,
                                              @Param("payStatus") Integer payStatus);

    ProductOrder findProductOrder(@Param("id") Integer id);

    List<CountVo> sumAmountByOrderType(@Param("userId") Integer userId,
                                       @Param("startDate") Date startDate,
                                       @Param("endDate") Date endDate);

    List<CountVo> countTaskByScene(@Param("userId") Integer userId,
                                   @Param("startDate") Date startDate,
                                   @Param("endDate") Date endDate);

    List<CountVo> countProductOrderTop3(@Param("userId") Integer userId, @Param("now") Date now);

    int updateState(ProductOrder productOrder);

    ProductOrder selectProductOrderByProcessInstanceId(@Param("processInstanceId") Integer processInstanceId,
                                                       @Param("runTimes") Integer runTimes);
}
